<template>
	<popup ref="popup" :loading="popupLoading">
		<div slot="body">
			<div class="dataTable autoFlex" v-if="listData">
				<qlh-table class="table" ref="userShoppingCartTable" :data="listData" stripe border 
				v-loading="listLoading" :tableToolButton="tableToolButton">
					<qlh-table-column prop="name" label="商品名称" sortable></qlh-table-column>
					<qlh-table-column prop="storeName" label="店铺名称" sortable></qlh-table-column>
					<qlh-table-column prop="param" label="规格参数"></qlh-table-column>
					<qlh-table-column prop="price" label="单价"></qlh-table-column>
					<qlh-table-column prop="count" label="数量"></qlh-table-column>
					<qlh-table-column prop="totalPrice" label="总价"></qlh-table-column>
				</qlh-table>
			</div>
			<div>总价：{{total}}</div>

		</div>
	</popup>
</template>

<script>
	import popup from '@/components/popup/dialogPopup.vue';
	import qlhTable from '@/components/qlhTable/qlhTable.vue';
	import qlhTableColumn from '@/components/qlhTable/qlhTableColumn.vue';
	import api from '@/api/tgb/userShoppingCart/userShoppingCart.js';
	export default {
		name: 'user',
		components: {
			qlhTable,
			qlhTableColumn,
			popup,
		},
		data() {
			return {
				disabled: false,
				popupLoading: false,
				confirmLoading: false,
				parameter: {},
				total:0,
				listLoading: false,
				listData:[],
				tableToolButton: [{
					name: "customButton",
					icon: "el-icon-arrow-down",
					func: this.customButton
				}],
			};
		},
		methods: {
			//打开弹框
			open(parameter, title, disabled, size) {
				this.parameter = parameter;
				this.disabled = disabled;
				this.$refs.popup.open(title, size);
				this.$nextTick(() => {
					this.init();
				})
			},
			//关闭弹框
			close() {
				this.disabled = false;
				this.$refs.popup.close();
			},
			init() {
				this.popupLoading = true;
				//清除等待
				this.confirmLoading = false;
				
				if (this.parameter.uid) {
					//编辑查询数据
					let parameter = {
						uid: this.parameter.uid
					};
					api.toUpdate(parameter, response => {
						console.log(response.data)
						// this.formParameter = this.$utils.merger(this.formParameter, response.data.user, {
						// 	roleId: response.data.userRole.rid
						// });
						this.listData = response.data.cartList
						// console.log(this.listData)
						this.total = response.data.total
						this.popupLoading = false;
					});
				} 
			}
		}
	};
</script>

<style lang="scss" scoped="scoped">
	@import '~common/custom/css/common.scss';
	@import '~common/custom/css/popup/popup.scss';
</style>
